/*
 *  Copyleft 2010 Marcos Garcia Ortega <a href="mailto:thiamath@gmail.com">&lt;thiamath@gmail.com&gt;</a>.
 * 
 *  Licensed under the GPL License, Version 3.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 * 
 *       http://www.gnu.org
 * 
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

package jgf.orders;

import jgf.IGraph;
import jgf.beans.NodeBean;
import jgf.exceptions.node.UnexistentNodeException;

/**
 *
 * @author Marcos Garcia Ortega <a href="mailto:thiamath@gmail.com">&lt;thiamath@gmail.com&gt;</a>
 */
public class InsertNode implements ReversibleOrder{
	
	private NodeBean node;

	public InsertNode(NodeBean node) {
		this.node = node;
	}

	public void execute(IGraph graph) {
		graph.insertNode(node.getLabel());
	}

	public void undo(IGraph graph) throws UnexistentNodeException{
		graph.deleteNode(node.getId());
	}

}
